<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>服务列表 - FuYuan RPC管理控制台</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div th:replace="fragments/header :: header"></div>

<div class="container mt-4">
    <h1>服务列表</h1>

    <div class="row mb-3">
        <div class="col-md-6">
            <form action="/services" method="get">
                <div class="input-group">
                    <input type="text" class="form-control" name="serviceName" placeholder="搜索服务名称"
                           th:value="${searchServiceName}">
                    <button class="btn btn-outline-secondary" type="submit">搜索</button>
                </div>
            </form>
        </div>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-hover">
            <thead>
            <tr>
                <th>服务名称</th>
                <th>版本</th>
                <th>分组</th>
                <th>地址</th>
                <th>端口</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="service : ${services}">
                <td th:text="${service.serviceName}">-</td>
                <td th:text="${service.serviceVersion}">-</td>
                <td th:text="${service.serviceGroup}">-</td>
                <td th:text="${service.serviceAddress}">-</td>
                <td th:text="${service.servicePort}">-</td>
                <td>
                    <span th:if="${service.status == 'online'}" class="badge bg-success">在线</span>
                    <span th:if="${service.status == 'offline'}" class="badge bg-secondary">离线</span>
                </td>
                <td>
                    <a th:href="@{/service/detail(serviceName=${service.serviceName})}" class="btn btn-sm btn-primary">详情</a>
                </td>
            </tr>
            <tr th:if="${services.isEmpty()}">
                <td colspan="7" class="text-center">暂无服务信息</td>
            </tr>
            </tbody>
        </table>
    </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>